package work823;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

public class work6Client {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    System.out.println("请输入图片路径");
    String str = sc.next();
    Socket socket = null;
    DataInputStream dis = null;
    OutputStream os = null;
    File file = new File(str);
    try {
      socket = new Socket("localhost",8888);
      os = socket.getOutputStream();
      DataOutputStream dos = new DataOutputStream(os);
      dis = new DataInputStream(new FileInputStream(file));
      os.write(file.getName().getBytes());
      int len = -1;
      while ((len = dis.read())!= -1){
        dos.write(len);
      }
      socket.shutdownOutput();
      socket.shutdownInput();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
}
//E:\\bdqn\\javaDemo\\2\\aaa.png
